<template>
  <div class="navbar">
    <div class="content">
      <div class="log">
        <div class="search"></div>
        <div class="wenzi">创思找工作</div>
      </div>
      <div class="describe">
        创思信息以“工匠精神”推动产业互联网升级，推动政府事务单位业务处理自动化，助力工业4.0转型升级！
      </div>
      <div class="title">预祝你在创思信息找到心仪工作</div>
      <div class="need">269+ 岗位需求</div>
      <div class="button-signup"><div class="wenzi">查看岗位</div></div>
      <div class="button-pub">
        <div class="rectangle"></div>
        <div class="wenzi">发布岗位</div>
      </div>
      <div class="low-navbar">
        <div class="wenzi">首页</div>
        <div class="wenzi">岗位展示</div>
        <div class="wenzi">工作分类</div>
        <div class="wenzi">关于创思</div>
      </div>

      <div class="to-login" v-if="username">
        <el-dropdown>
          <span class="el-dropdown-link">
            <div class="imgage" :class="img ? 'haveimg' : 'noimg'"></div>
          </span>
          <template #dropdown>
            <el-dropdown-menu>
              <el-dropdown-item>{{ username }}</el-dropdown-item>
              <el-dropdown-item divided @click="push('/login-manage/infoimprove')">完善个人信息</el-dropdown-item>
              <el-dropdown-item divided @click="logout"><span style="color: red">退出登录</span></el-dropdown-item>
            </el-dropdown-menu>
          </template>
        </el-dropdown>
      </div>
      <div class="to-login" @click="push('/login-manage/login')" v-else>登录</div>
    </div>
  </div>
</template>

<script>
import { useRouter } from 'vue-router'
import { reactive, toRefs } from 'vue'

export default {
  setup(props) {
    const Router = useRouter()
    const userInfo = reactive(JSON.parse(localStorage.getItem('token')))

    function logout() {
      userInfo.username = ''
      localStorage.removeItem('token')
    }

    return {
      ...toRefs(userInfo),
      push: Router.push,
      logout
    }
  }
}
</script>

<style lang="less">
.navbar {
  position: absolute;
  left: 0px;
  top: 0px;
  width: 1440px;
  height: 771.5px;
  background: linear-gradient(244deg, #2a2ad1 -5%, #2a2ad1 -5%, #4d4ddb 108%, #4d4ddb 108%);
  background: url('../images/Navbar.png');
  .content {
    position: absolute;
    left: 65px;
    top: 23px;
    width: 1302px;
    height: 559px;
    .log {
      position: absolute;
      left: 2px;
      top: 0px;
      width: 270px;
      height: 95px;
      .search {
        position: absolute;
        left: 0px;
        top: 0px;
        width: 95px;
        height: 95px;
        background: url('../images/flat-color-icons_search.png');
      }
      .wenzi {
        position: absolute;
        left: 110px;
        top: 29px;
        width: 160px;
        height: 37.5px;
        font-size: 32px;
        font-weight: normal;
        line-height: 37.5px;
        letter-spacing: 0em;
        color: #ffffff;
      }
    }
    .describe {
      position: absolute;
      left: 0px;
      top: 381px;
      width: 528px;
      height: 140.63px;

      font-size: 24px;
      font-weight: normal;
      line-height: 28.13px;
      letter-spacing: 0em;
      color: #ffffff;
    }
    .title {
      position: absolute;
      left: 0px;
      top: 283px;
      width: 784px;
      height: 65.63px;
      font-size: 56px;
      font-weight: normal;
      line-height: 65.63px;
      letter-spacing: 0em;
      color: #ffffff;
    }
    .need {
      position: absolute;
      left: 2px;
      top: 195px;
      width: 327px;
      height: 56.25px;
      font-size: 48px;
      font-weight: normal;
      line-height: 56.25px;
      letter-spacing: 0em;
      color: #ffffff;
    }
    .button-signup {
      position: absolute;
      left: 0px;
      top: 508px;
      width: 144px;
      height: 50.75px;
      display: flex;
      padding: 16px 40px;
      border-radius: 8px;
      background: #000000;
      box-sizing: border-box;
      .wenzi {
        position: absolute;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%);
        width: 64px;
        height: 18.75px;
        font-family: RobotoRoman-Medium;
        font-size: 16px;
        font-weight: normal;
        line-height: 18.75px;
        letter-spacing: 0em;
        color: #ffffff;
        z-index: 0;
      }
    }
    .button-pub {
      position: absolute;
      left: 1125px;
      top: 22px;
      width: 177px;
      height: 55px;
      border-radius: 8px;
      .wenzi {
        /* 发布岗位 */

        position: absolute;
        left: 42px;
        top: 18px;
        width: 80px;
        height: 23.44px;
        font-family: RobotoRoman-Medium;
        font-size: 20px;
        font-weight: normal;
        line-height: 23.44px;
        letter-spacing: 0em;
        color: #ffffff;
      }
      .rectangle {
        /* Rectangle 5 */

        position: absolute;
        left: 0px;
        top: 0px;
        width: 177px;
        height: 55px;
        border-radius: 8px;
        background: #000000;
      }
    }
    .low-navbar {
      /* Navbar */
      display: flex;
      justify-content: space-between;
      position: absolute;
      left: 447px;
      top: 36px;
      width: 492px;
      height: 28.13px;
      .wenzi {
        font-size: 24px;
        line-height: 28.13px;
        color: #ffffff;
      }
    }
    .to-login {
      position: absolute;
      left: 1005px;
      top: 36px;
      width: 48px;
      height: 28.13px;
      font-size: 24px;
      font-weight: normal;
      line-height: 28.13px;
      letter-spacing: 0em;
      color: #ffffff;
      &:hover {
        cursor: pointer;
      }
      .el-dropdown-link {
        cursor: pointer;
        color: #ffffff;
        font-size: 24px;
        display: flex;
        align-items: center;
        width: 50px;
        height: 50px;
      }
      .imgage {
        position: absolute;
        left: 1px;
        top: 0px;
        width: 50px;
        height: 50px;
        border-radius: 50%;
        border: 2px solid #4d4ddb;
        overflow: hidden;
      }
      .noimg {
        background: url('../images/ant-design_user-outlined.png') no-repeat;
        background-size: contain;
      }
      .haveimg {
        background: url('../images/Testinomi 1.png') no-repeat 50% 50%;
        background-size: 170%;
      }
    }
  }
}
</style>
